package com.ruibang.glass.material.service.impl.nydl;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruibang.glass.material.domain.req.ycl.ManageLocationReq;
import com.ruibang.glass.material.entity.nydl.MaterialNYDLLocationManagement;
import com.ruibang.glass.material.mapper.nydl.GMaterialNYDLLocationManagementMapper;
import com.ruibang.glass.material.service.nydl.GMaterialNYDLLocationManagementService;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 原材料库位管理表 服务实现类
 * </p>
 *
 * @author mameng
 * @since 2024-04-01
 */
@Service
public class GMaterialNYDLLocationManagementServiceImpl extends ServiceImpl<GMaterialNYDLLocationManagementMapper, MaterialNYDLLocationManagement> implements GMaterialNYDLLocationManagementService {

    @Override
    public IPage<MaterialNYDLLocationManagement> getPage(ManageLocationReq manageLocationReq) {
        LambdaQueryWrapper<MaterialNYDLLocationManagement> queryWrapper = Wrappers.<MaterialNYDLLocationManagement>lambdaQuery();
        if (StringUtils.isNotBlank(manageLocationReq.getLocationName())) {
            queryWrapper.like(MaterialNYDLLocationManagement::getLocationName, manageLocationReq.getLocationName());
        }
        if (StringUtils.isNotBlank(manageLocationReq.getLocationName())) {
            queryWrapper.like(MaterialNYDLLocationManagement::getLocationName, manageLocationReq.getLocationName());
        }
        if (StringUtils.isNotBlank(manageLocationReq.getStatus())) {
            queryWrapper.like(MaterialNYDLLocationManagement::getStatus, manageLocationReq.getStatus());
        }
        Page<MaterialNYDLLocationManagement> materialWarehouseInfoPage = baseMapper.selectPage(new Page<>(manageLocationReq.getPageNo(), manageLocationReq.getPageSize()),
                queryWrapper.orderByDesc(MaterialNYDLLocationManagement::getCreateTime)
        );
        return materialWarehouseInfoPage;
    }
}
